#include "Test/TestWindow1.h"
#include "Controls/Button.h"
#include "Controls/TextBlock.h"
#include "Controls/Panels/StackPanel.h"

#include <memory>
#include <string>
namespace test
{
using namespace cxgui;
using namespace ci;
using namespace std;

TestWindow1::TestWindow1()
	: CxWindow()
{
	_clientRectangle.set(10.f, 10.f, 300.f, 300.f);

	auto panel = make_shared<StackPanel>();
	for(int i = 0 ; i < 4; i++)
	{
	auto button = make_shared<Button>("OK " + to_string(i));
	button->SetMargin(5.f);
	button->SetHorizontalAlignment(HorizontalAlignment::Stretch);
	panel->AddControl(button);
	}
	
	this->SetContent(panel);
}

void TestWindow1::AddButton()
{
	auto button = make_shared<Button>("New Button");
	button->SetMargin(5.f);
	button->SetHorizontalAlignment(HorizontalAlignment::Stretch);
	auto& panel = dynamic_cast<Panel&>(*_content);
	panel.AddControl(button);
}

void TestWindow1::RemoveButton()
{
	auto& panel = dynamic_cast<Panel&>(*_content);
	if(panel.GetControlsCount() > 0)
	{
		panel.RemoveControl(panel.GetControlsCount() - 1);
	}
}



}